@import "@influxdata/clockface/dist/variables.scss";

$notebook-header-height: 46px;
$notebook-size-toggle: 16px;
$notebook-left-bar: 22px;
$notebook-panel--bg: mix($g1-raven, $g2-kevlar, 50%);

$notebook-divider-height: ($cf-marg-a * 2) + $cf-border;

.notebook {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.notebook-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-radius: $cf-radius;

  &:after {
    content: '';
    height: $cf-border;
    background-color: $g2-kevlar;
    border-radius: $cf-border / 2;
    margin: $cf-marg-a 0;
  }
}

// Highlight panel on hover
.notebook-panel--header,
.notebook-panel--body {
  transition: background-color 0.25s ease;
}

.notebook-panel:hover {
  .notebook-panel--header,
  .notebook-panel--body {
    background-color: $notebook-panel--bg;
  }
}

.notebook-panel--header {
  border-radius: $cf-radius $cf-radius 0 0;
  height: $notebook-header-height;
  flex: 0 0 $notebook-header-height;
  padding: 0 $cf-marg-b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notebook-panel--header-left,
.notebook-panel--header-right {
  flex: 1 0 $notebook-header-height;
}

.notebook-panel--header-right {
  transition: opacity 0.25s ease;
  opacity: 0;
}

.notebook-panel:hover .notebook-panel--header-right {
  opacity: 1;
}

.notebook-panel--title,
.notebook-panel--data-source {
  font-size: 14px;
  font-weight: $cf-font-weight--medium;
  user-select: none;
  margin-right: $cf-marg-b !important;
}

.notebook-panel--title {
  color: $g15-platinum;
}

.notebook-panel--data-source {
  color: $c-laser;
}

.notebook-panel--editable-title {
  background-color: transparent;
  border: 0;
  color: $g15-platinum;
  font-size: 14px;
  font-family: $cf-text-font;
  font-weight: $cf-font-weight--medium;
  transition: color 0.25s ease, background-color 0.25s ease;
  outline: none;
  width: 228px;

  &:hover,
  &:focus {
    color: $g20-white;
  }
}

.notebook-panel--data-caret {
  display: inline-block;
  margin-left: $cf-marg-a;
  font-size: 0.8em;
  position: relative;
  top: -2px;
}

.notebook-panel--toggle {
  top: 0;
  left: 0;
  width: $notebook-left-bar;
  background-color: $g2-kevlar;
  border-radius: $cf-radius;
  height: 100%;
  position: absolute;

  &:after {
    box-sizing: border-box;
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: $notebook-size-toggle;
    transition: height 0.25s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.25s ease;
    border: $cf-border solid $g8-storm;
    border-radius: $cf-radius / 2;
  }

  &:hover {
    cursor: pointer;
    &:after {
      border-color: $g13-mist;
    }
  }
}

.notebook-panel--body {
  border-radius: 0 0 $cf-radius $cf-radius;
  padding: $cf-marg-b;
  padding-top: 0;
  // flex: 1 0 0;
  position: relative;
}

// Special styling for query builder inside notebook panel
.notebook-panel--body .query-builder {
  position: relative;
  height: 320px;
  width: 100%;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  padding-top: 0;
}

.notebook-panel--body .flux-editor {
  position: relative;
  height: 320px;
  width: 100%;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

// Special styling for markdown panels
.notebook-panel--markdown,
.notebook-panel--markdown-edit {
  font-size: 14px;
  padding: $cf-marg-b;
  border-radius: $cf-radius - 1px;
  border-width: $cf-border;
  border-style: solid;
}

.notebook-panel--markdown {
  border-color: $notebook-panel--bg;
}

.notebook-panel--markdown-edit {
  padding: $cf-marg-b;
  background-color: $g1-raven;
  border-color: $cf-input-border--default;
  color: $cf-input-text--default;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  transition: $cf-input--transition;
  outline: none;

  &:hover {
    color: $cf-input-text--hover;
    border-color: $cf-input-border--hover;
  }

  &:focus {
    color: $cf-input-text--focused;
    border-color: $cf-input-border--focused;
    box-shadow: $cf-input--box-shadow;
  }
}

.notebook-panel--results {
  width: 100%;
  height: 320px;
  position: relative;
}

/*
  Notebook Panel Modes
  ------------------------------------------------------------------------------
*/

.notebook-panel__hidden {
  height: $notebook-header-height + $notebook-divider-height;

  .notebook-panel--body {
    display: none;
  }

  .notebook-panel--header {
    border-radius: $cf-radius;
  }
}

.notebook-panel__visible {
  min-height: $notebook-header-height;
}

/*
  Notebook Action Bar aka Footer
  ------------------------------------------------------------------------------
*/

.notebook--actions {
  margin-top: $cf-marg-c;
}

/*
  Visualization Panel
  ------------------------------------------------------------------------------
*/

.notebook-panel--visualization {
  width: 100%;
  height: 320px;
  display: flex;
  align-items: stretch;
  flex-direction: row;
}

.notebook-panel--view {
  flex: 1 0 0;
  position: relative;
}

// Special styling for view options inside notebook panel
.notebook-panel--body .view-options {
  flex: 0 0 340px;
  border-radius: 0;
  background-color: transparent;
  margin-right: 0;
}
.notebook-panel--body .view-options--container {
  padding: $cf-marg-c;
}

.notebook-header--buttons {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: wrap;

    > * {
        margin-left: 4px;
    }
}
